module.exports = function ($scope, $state, $resource, $modalInstance,$modal, toaster,item,flag ){
    
        
        init();
        function init(){
           
            if(item == '1'){
                console.log(item);
                $scope.obj = [];
            }else{
                $scope.obj = flag ? {'flag': true} : angular.copy(item);
            }
            // $scope.search();
           
        }
    
    
        $scope.save = function(){
            // if($scope.obj.title == undefined){
            //     toaster.error({title: '', body: '请输入游团标题！'});
            //   return;
            // }
            // if($scope.obj.tour_type == undefined){
            //     toaster.error({title: '', body: '请选择游团类型！'});
            //   return;
            // }
            // if($scope.obj.managger_name == undefined){
            //     toaster.error({title: '', body: '请输入负责人姓名！'});
            //   return;
            // }
            // if($scope.obj.managger_mobile == undefined){
            //     toaster.error({title: '', body: '请输入手机号！'});
            //   return;
            // }
            // if($scope.obj.managger_card_no == undefined){
            //     toaster.error({title: '', body: '请输入身份证号！'});
            //   return;
            // }
    
            $resource('/api/as/goc/citydiscount/saveBase', {}, {}).save($scope.obj,function (res) {
                console.log($scope.obj);
                if(res.errcode === 0){
                    toaster.success({title: '', body: '保存成功'});
                    
                }else{
                    toaster.error({title: '', body: res.errmsg});
                }
                $modalInstance.close();
            });
        }
         //取消
    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
        }
    }